<template>
	<view class="height-screen">
		<cu-custom bgColor="bg-white" isBack>
			<block slot="content">{{$t('mine.setting')}}</block>
		</cu-custom>
		<view class="bg-white margin-ht grid padding-lg radius-sm" style="margin-top: 20rpx;gap: 50rpx;">
			<text class="text-black font-400" style="font-size: 30rpx;"
				@tap.stop="helper.routerNav('/pages/mine/rechargePhone')">{{$t('filed.huanbang')}}</text>
			<view class="flex justify-between align-center" @tap.stop="langSHow = true;">
				<text class="text-black font-400" style="font-size: 30rpx;">{{$t('filed.qiehuan')}}</text>
				<view class="flex align-center">
					<text class="text-gray font-400" style="font-size: 30rpx;">{{currentLang}}</text>
					<text class="text-gray cuIcon-right margin-left-sm" />
				</view>
			</view>
			<text class="text-black font-400" style="font-size: 30rpx;"
				@tap.stop="helper.routerNav('/pages/mine/xieyi',{type:'user'})">{{$t('xieyi.user')}}</text>
			<text class="text-black font-400" style="font-size: 30rpx;"
				@tap.stop="helper.routerNav('/pages/mine/xieyi',{type:'yinsi'})">{{$t('xieyi.yinsi')}}</text>
			<text class="text-black font-400" style="font-size: 30rpx;"
				@tap.stop="helper.routerNav('/pages/mine/withdraw')">{{$t('user.zhuxiao')}}</text>
			<text class="text-black font-400" style="font-size: 30rpx;"
				@tap.stop="handleLogOut">{{$t('filed.tuichu')}}</text>
		</view>
		<u-action-sheet :show="langSHow" :actions="langActions" @close="langSHow = false" @select="langSelect"
			safeAreaInsetBottom />
	</view>
</template>

<script>
	export default {
		data() {
			return {
				currentLang: '',
				langSHow: false,
				langActions: [{
						name: this.$t('filed.zhong'),
					},
					{
						name: this.$t('filed.ying'),
					}
				],
			}
		},
		onShow() {
			let lang = uni.getStorageSync('lang')
			this.currentLang = lang == 'en' ? this.$t('filed.ying') : this.$t('filed.zhong')
		},
		methods: {
			langSelect(e) {
				this.currentLang = e.name
				if (e.name == this.$t('filed.zhong')) {
					this.helper.setStorageSync('lang', 'zh-cn')
					this.$i18n.locale = 'zh-Hans'
				} else {
					this.helper.setStorageSync('lang', 'en')
					this.$i18n.locale = 'en'
				}
				this.helper.showToast(this.$t('message.success'))
			},
			handleLogOut() {
				this.helper.removeStorageSync('token')
				uni.reLaunch({
					url: '/pages/tabBar/login'
				})
			}
		}
	}
</script>

<style lang="scss" scoped>
</style>